package cn.cnooc.entity;

import java.io.Serializable;

import lombok.Data;

/**
 * Serializable接口是启用其序列化功能的接口
 * 
 * @author HH
 *
 */
@Data
public class Result implements Serializable {

	private static final long serialVersionUID = -5160007122274578019L;

	private int code;
	private String msg;
	private Object data;

	public static final Result success() {
		return get(Status.OK.getCode(), Status.OK.getMsg(), null);
	}

	public static final Result success(Object data) {
		return get(Status.OK.getCode(), Status.OK.getMsg(), data);
	}

	public static final Result success(String msg, Object data) {
		return get(Status.OK.getCode(), msg, data);
	}

	public static final Result fail() {
		return get(Status.FAIL.getCode(), Status.FAIL.getMsg(), null);
	}

	public static final Result fail(String msg) {
		return get(Status.FAIL.getCode(), msg, null);
	}

	public static final Result fail(String msg, Object data) {
		return get(Status.FAIL.getCode(), msg, data);
	}

	public static final Result error() {
		return get(Status.ERROR.getCode(), Status.ERROR.getMsg(), null);
	}

	public static final Result error(String msg) {
		return get(Status.ERROR.getCode(), msg, null);
	}

	public static final Result error(String msg, Object data) {
		return get(Status.ERROR.getCode(), msg, data);
	}

	public static final Result get(int code, String msg, Object data) {
		Result result = new Result();
		result.setCode(code);
		result.setMsg(msg);
		result.setData(data);
		return result;
	}
}
